<h1>Courses Management</h1>
<div class="subHeader">
	<b>Courses List</b>
</div>
<?php
	$list = $mvc->getObject('list');
	if(!isset($list) || count($list) == 0){
?>
	<span class="message warning">
		Sorry, there are no courses available at this moment.<br />
		You can create new <a href="/new-course.html" title="New Course">Course.</a>
	</span>
<?php } else { ?>

<table class="list">
	<tr>
		<th>Caption:</th>
		<th>Create Date:</th>
		<th>Category:</th>
		<th>Rate:</th>
		<th>Options:</th>
	</tr>
<?php foreach($list as $key => $value){ ?>
	<tr <?php if($key%2)echo "class='pair'" ?>>
		<td>
			<a href=<?php echo 'course-details.html?id=' . $value[CourseService::ID];?>>
				<?php echo $value[CourseService::CAPTION];?>
			</a>
		</td>
		<td><?php echo $value[CourseService::CRDATE];?></td>
		<td>
			<a href="/manage-courses.html?id=<?php echo $value[CourseService::CATEGORY_ID];?>">
 				<?php echo $value[CategoriesService::NAME];?>
 			</a>
		</td>
		<td>
			<?php if($value[CourseService::RATE] >= 1){ ?>
			<img src="images/star.png" /> <?php }else{ ?> <img src="images/gray-star.png" /><?php } ?>
			<?php if($value[CourseService::RATE] >= 2){ ?>
			<img src="images/star.png" /> <?php }else{ ?> <img src="images/gray-star.png" /><?php } ?>
			<?php if($value[CourseService::RATE] >= 3){ ?>
			<img src="images/star.png" /> <?php }else{ ?> <img src="images/gray-star.png" /><?php } ?>
			<?php if($value[CourseService::RATE] >= 4){ ?>
			<img src="images/star.png" /> <?php }else{ ?> <img src="images/gray-star.png" /><?php } ?>
			<?php if($value[CourseService::RATE] >= 5){ ?>
			<img src="images/star.png" /> <?php }else{ ?> <img src="images/gray-star.png" /><?php } ?>
		</td>
		<td>
			<a class="button" href=<?php echo 'edit-course.html?id=' . $value[CourseService::ID];?>>Edit</a>
			<a class="button" onclick="return confirm('You sure you want to delete?');"  href=<?php echo 'manage-courses.html?deleted=' . $value[CourseService::ID];?>>Delete</a>
		</td>
	</tr>
<?php } ?> 
</table>
<?php } ?>